// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
// By default we import all the components.
// Only reserve the components on demand and remove the rest.
// Style is always required.
import {
  /* eslint-disable no-unused-vars */
  Style,
  // basic
  Button,
  Loading,
  Tip,
  Toolbar,
  TabBar,
  TabPanels,
  // form
  Checkbox,
  CheckboxGroup,
  Checker,
  Radio,
  RadioGroup,
  Input,
  Textarea,
  Select,
  Switch,
  Rate,
  Validator,
  Upload,
  Form,
  // popup
  Popup,
  Toast,
  Picker,
  CascadePicker,
  DatePicker,
  TimePicker,
  SegmentPicker,
  Dialog,
  ActionSheet,
  Drawer,
  ImagePreview,
  // scroll
  Scroll,
  Slide,
  IndexList,
  Swipe,
  Sticky,
  ScrollNav,
  ScrollNavBar,
  RecycleList
} from "cube-ui";

import App from "./App";
import router from "./router";
import store from "./store";
import VueResource from "vue-resource";
import VConsole from "vconsole";
import "amfe-flexible";

import filters from "./filter/index";

import { toast, toastErrorCode } from "./utils/toast";

if (process.env.NODE_ENV === "development") {
  // require("./mock/index.js");
  // Vue.use(new VConsole());
} else {
  console.log = function () {
    return false;
  };
}

Vue.use(Button);
Vue.use(Loading);
Vue.use(Tip);
Vue.use(Toolbar);
Vue.use(TabBar);
Vue.use(TabPanels);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Checker);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(Input);
Vue.use(Textarea);
Vue.use(Select);
Vue.use(Switch);
Vue.use(Rate);
Vue.use(Validator);
Vue.use(Upload);
Vue.use(Form);
Vue.use(Popup);
Vue.use(Toast);
Vue.use(Picker);
Vue.use(CascadePicker);
Vue.use(DatePicker);
Vue.use(TimePicker);
Vue.use(SegmentPicker);
Vue.use(Dialog);
Vue.use(ActionSheet);
Vue.use(Drawer);
Vue.use(ImagePreview);
Vue.use(Scroll);
Vue.use(Slide);
Vue.use(IndexList);
Vue.use(Swipe);
Vue.use(Sticky);
Vue.use(ScrollNav);
Vue.use(ScrollNavBar);
Vue.use(RecycleList);
Vue.use(VueResource);

Vue.config.productionTip = false;

Vue.prototype.$toast = toast;
Vue.prototype.$toastErrorCode = toastErrorCode;

/* filter */
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
})

/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  store,
  template: "<App/>",
  components: { App }
});
